package startup

import (
	"git.mycaigou.com/gfyx/micro-gfyx-user-service/infrastructure/vars"
	"git.mycaigou.com/ycg/stark-extend/starkcommon"
	"git.myscrm.cn/golang/stark/v4/module/helper"
)

// SetupVars 加载变量
func SetupVars() error {
	err := starkcommon.SetupVars()
	if err != nil {
		return err
	}

	err = SetupCustomerVars()
	if err != nil {
		return err
	}

	return nil
}

// SetupCustomerVars 设置自定义变量
func SetupCustomerVars() error {
	var err error
	if vars.TenantDbMysqlSetting != nil && vars.TenantDbMysqlSetting.Host != "" {
		vars.TenantDbMysqlSetting.ParseTime = true
		vars.TenantDBMySQLConn, err = helper.NewMySQLConn(vars.TenantDbMysqlSetting)
		if err != nil {
			return err
		}
	}
	return nil
}
